package model

import (
	"time"
)

type Users struct {
	UsersVisually `xorm:"extends"`
	AppsId        uint      `json:"apps_id" xorm:"not null comment('app id') unique(apps_account) INT"`
	Token         string    `json:"token" xorm:"comment('令牌') VARCHAR(255) index"`
	Status        int       `json:"status" xorm:"not null default 1 comment('状态 -1:删除 0:禁用 1:正常') TINYINT(4)"`
	Created       time.Time `json:"created" xorm:"'created' created TIMESTAMP"`
	Updated       time.Time `json:"updated" xorm:"'updated' updated TIMESTAMP"`
	Password      string    `json:"password" xorm:"not null comment('pass') VARCHAR(255)"`
}
type UserModifiable struct {
	Nickname     string    `json:"nickname" xorm:"not null comment('昵称') VARCHAR(16)"`
	LastOnlineAt time.Time `json:"-" xorm:"TIMESTAMP comment('最后在线时间')"`
	LastLoginAt  time.Time `json:"-" xorm:"TIMESTAMP comment('最后登录时间')"`
	Avatar       string    `json:"avatar" xorm:"not null comment('头像url') VARCHAR(255)"`
	PushToken    string    `json:"push_token" xorm:"push_token default '' varchar(128)"`
	// 封面图
	CoverImage string `json:"cover_image" xorm:"cover_image not null comment('封面') VARCHAR(255)"`
}

// 可展示字段
type UsersVisually struct {
	UserModifiable `xorm:"extends"`
	Followers      int64  `json:"followers" xorm:"followers not null int"`
	Focus          int64  `json:"focus" xorm:"focus not null int"`
	Id             int64  `json:"id" xorm:"not null pk autoincr BIGINT"`
	Account        string `json:"account" xorm:"not null comment('账号') unique(apps_account) VARCHAR(11)"`
}

func (u *Users) TableName() string {
	return "users"
}
